﻿@model  Logic.Models.TaskCreateModel
@{
    Layout = null;
}
<script type="text/javascript" src="/uploadify/swfobject.js"></script>
<script type="text/javascript" src="/uploadify/jquery.uploadify.v2.1.4.min.js"></script>
 <div class="HeaderContainer">
     <div class="TaskHeader">
            <img src="@(Logic.Constants.CurrentUrl)/Images/TaskBigIcon.png" class="Icon TaskIcon"/>
            <div class="Property  Name">
                <div class="Label">Name:</div>
                @Html.TextBox("Name","")
                <span class="Mandatory">*</span>
            </div>
        </div>
</div>


<div id="task_tabs" class="tabs">
    <div class="tabHeaderContainer">
        <ul>
        <li><a href="#tabs-1">Info</a></li>
        <li><a href="#tabs-2">Documents</a></li>
    </ul>
    </div>
    <div class="Info_Container" id="tabs-1">
        <div class="Row">
            <div class="Property">
                <div class="Label">
                    Start Date</div>
                <div>@Html.TextBox("StartDate","", new { Class ="Date" })</div>
            </div>
            <div class="Property">
                <div class="Label">
                    Due date</div>
                <div>
                    <input type="text" name="DueDate" class="Date" /></div>
            </div>
            <div class="Property">
                <div class="Label">
                    Create In</div>
                <div>
                    <select name="ParentID" id="OriginatedFromID">
                        <option value="">@Logic.Constants.DEFAULT_TASK_CONTAINER</option>
                    </select></div>
            </div>
        </div>
        <div class="Row">
            <div class="Label">
                Description</div>
            <textarea id="Description" name="Description" rows="5" cols="20"></textarea>
        </div>
        <div class="Row AdditionalFieldsContainer">
            <div class="Label Link">
                <span id="AdditionalFieldsLink">+ Additional Fields</span>
            </div>
            <div class="AdditionalFields">
                <div class="Row">
                    <div class="Property">
                        <div class="Label">
                            State</div>
                        <div>@Html.DropDownList("StateID", new SelectListItem[] { new SelectListItem { Text ="Draft", Value ="Draft" } }, new { disabled ="disabled" })</div>
                        @*<div>@Html.DropDownList("StateID", Model.States.Select(u => new SelectListItem { Text = u.Name, Value = u.Id.Value, Selected = u.Name == Logic.Constants.DefaultState }))</div>*@

                    </div>
                    <div class="Property">
                        <div class="Label">
                            Status</div>
                        <div>@Html.DropDownList("TrackStatusID", Model.Statuses.Select(u => new SelectListItem { Text = u.Values[0].Value.ToString(), Value = u.Id.Value, Selected = u.Values[0].Value.ToString() == Logic.Constants.DefaultStatus }))</div>
                    </div>
                    <div class="Property">
                        <div class="Label">
                            Importance</div>
                        <div>@Html.DropDownList("ImportanceID", Model.Importance.Select(u => new SelectListItem { Text = u.Values[0].Value.ToString(), Value = u.Id.Value, Selected = u.Values[0].Value.ToString() == Logic.Constants.DefaultImportance }))</div>
                    </div>
                </div>
                <div class="Row">
                    <div class="Property">
                        <div class="Label">
                            Duration</div>
                        <div class="Duration">
                            <input type="text" class="Numeric" name="Duration.Value" />
                            @Html.DropDownList("Duration.Unit", Enum.GetNames(typeof(Logic.ClarizenSvc.DurationUnit)).Select(u => new SelectListItem { Text = u, Value = u, Selected = u == "Days" }))
                        </div>
                    </div>
                    <div class="Property">
                        <div class="Label">
                            Work</div>
                        <div class="Duration">
                            <input type="text" class="Numeric" name="Work.Value" />
                            @Html.DropDownList("Work.Unit", Enum.GetNames(typeof(Logic.ClarizenSvc.DurationUnit)).Select(u => new SelectListItem { Text = u, Value = u, Selected = u =="Hours" }))
                        </div>
                    </div>
                    <div class="Property">
                        <div class="Label">
                            % Completed</div>
                        <div>
                            <input type="text" class="Numeric" name="PercentCompleted" /></div>
                    </div>
                </div>
                <div class="Row">
                    <div class="Property">
                        <div class="Label">
                            Task Type</div>
                        <div>@Html.DropDownList("TaskTypeID", Model.TaskTypes.Select(u => new SelectListItem { Text = u.Values[0].Value.ToString(), Value = u.Id.Value, Selected = u.Values[0].Value.ToString() == Logic.Constants.DefaultTaskType }))</div>
                    </div>
                    <div class="Property">
                        <div class="Label">
                            Manager</div>
                        <div>
                            <select name="ManagerID" id="AssignedTo">
                            </select></div>
                    </div>
                </div>
                <div class="Row">
                    <div class="Property">
                        <div id='Resources' name='Resources' class='autocomplete' url='@(Logic.Constants.CurrentUrl)/users/index'>
                        </div>
                    </div>
                </div>
                <div class="Row CustomContainer">
                    <div class="Property">
                        <span id="CustomFieldsLink" class="Link Label">+ Custom Fields</span>
                    </div>

                    <div id="CustomFields" class="Row">
                    </div>
                </div>
                
            </div>
            <div class="Row"></div>
        </div>
    </div>
    <div class="Documents_Container" id="tabs-2">
        @{Html.RenderPartial("~/Views/Documents/_DocumentsTab.cshtml", new ClarizenGadget.Models.DocumentViewModel { DocumentTypes = Model.DocumentTypes, AuthorizedGoogle = Model.AuthorizedGoogle});}
    </div>
</div>

<link href="@(Logic.Constants.CurrentUrl)/Content/tabs.min.css" rel="stylesheet" type="text/css" />

<script type="text/javascript">
    function getData()
    {
        var data = $('.Info_Container, .TaskHeader').find('input, textarea, select').serialize();
        data += getDocumentsData();

        return data;
    }

    function validateNew()
    {
        var val = $("[name=Name]").val()
        if (!val || val.replace(/\s/g, "") == "")
        {
            alert("You must type a name.");
            return false;
        }

        return true;
    }

    $(document).ready(function () {
        $('#AdditionalFieldsLink').click(function () {
            $('.AdditionalFields').toggle();

            var pos = $(".AdditionalFields").position().top + $(".Info_Container").scrollTop();
            $('.Info_Container').scrollTop(pos);

            var text = ($('.AdditionalFields').is(":visible") ? "-" : "+") +
                    " Additional Fields";
            $('#AdditionalFieldsLink').html(text);
        });

        $('#task_tabs').tabs();
        $("#Name").focus();
        

    });
    
</script>
